package com.blue.spring.convertor;

import java.time.LocalDate;

import org.springframework.core.convert.converter.Converter;

/**
 * 字符串转化为本地日期
 * 
 * @author zhengj
 * @since 1.0 2016年7月16日
 */
public class StringToLocalDateConvertor implements Converter<String, LocalDate>
{
	public StringToLocalDateConvertor()
	{
	}

	@Override
	public LocalDate convert(String text)
	{
		if (text == null || text.isEmpty())
			return null;

		if (text.length() > 10)
			text = text.substring(0, 10);

		return LocalDate.parse(text);
	}
}
